/**
 * @a https://leetcode.cn/problems/missing-two-lcci/
 */

#include "common.h"

class Solution
{
public:
    vector<int> missingTwo(vector<int> &nums)
    {
        int sz = nums.size(), xor_two = 0;
        for (auto num : nums)
            xor_two ^= num;
        for (int i = 1; i <= sz + 2; ++i)
            xor_two ^= i;

        int lowbit = xor_two & (-xor_two);
        int arr[2]{0,0};
        for (auto num : nums)
            arr[(num & lowbit) > 0 /*? 1 : 0*/] ^= num;
        for (int i = 1; i <= sz + 2; ++i)
            arr[(i & lowbit) > 0 /*? 1 : 0*/] ^= i;
        return {arr[0], arr[1]};
    }
};